//  this library.
import 'package:hktk_app/model/industry/category_model.dart';

/// 套餐对应模型
class PackageModel {
  String? createdTime;
  String? modifyTime;
  String? createdBy;
  String? modifyBy;
  String? id;
  String? name;

  // 排序
  int? sort;

  // 行业id 值为gjtk时表示考试为高教题库
  String? industryId;

  // 考试id
  String? examId;

  // 原价/分
  int? price;

  // 折扣价/分
  int? discountPrice;

  // 代理价/分
  int? agentPrice;

  // 天猫价/分
  int? tmPrice;

  // 标签ids
  List<String>? tagIds;

  // 有效天数
  int? days;

  // 有效日期
  String? endDate;
  String? remark;

  // 是否上下架
  bool? enable;

  // 是否上下架
  SkuAttrs? skuAttrs;

  // 行业名称
  String? industryName;

  // 考试名称
  String? examName;
  List<String>? tagNameList;
  List<String>? tagTypeList;
  List<String>? skuAttrNameList;
  String? examType;

  // sku管理
  List<SkuModel>? skuModels;

  // 判断是否显示推荐按钮，为1时显示推荐
  bool? recommend;

  PackageModel({
    this.createdTime,
    this.modifyTime,
    this.createdBy,
    this.modifyBy,
    this.id,
    this.name,
    this.sort,
    this.industryId,
    this.examId,
    this.price,
    this.discountPrice,
    this.agentPrice,
    this.tmPrice,
    this.tagIds,
    this.days,
    this.endDate,
    this.remark,
    this.enable,
    this.skuAttrs,
    this.industryName,
    this.examName,
    this.tagNameList,
    this.tagTypeList,
    this.skuAttrNameList,
    this.examType,
    this.skuModels,
    this.recommend,
  });

  PackageModel.fromJson(Map<String, dynamic> json) {
    createdTime = json['createdTime'];
    modifyTime = json['modifyTime'];
    createdBy = json['createdBy'];
    modifyBy = json['modifyBy'];
    id = json['id'];
    name = json['name'];
    sort = json['sort'];
    industryId = json['industryId'];
    examId = json['examId'];
    price = json['price'];
    discountPrice = json['discountPrice'];
    agentPrice = json['agentPrice'];
    tmPrice = json['tmPrice'];
    if (json["tagIds"] != null) {
      tagIds = json['tagIds'].cast<String>();
    }
    days = json['days'];
    endDate = json['endDate'];
    remark = json['remark'];
    enable = json['enable'];
    skuAttrs =
    json['skuAttrs'] != null ? SkuAttrs.fromJson(json['skuAttrs']) : null;
    industryName = json['industryName'];
    examName = json['examName'];
    if (json["tagNameList"] != null) {
      tagNameList = json['tagNameList'].cast<String>();
    }
    if (json["tagTypeList"] != null) {
      tagTypeList = json['tagTypeList'].cast<String>();
    }
    if (json["skuAttrNameList"] != null) {
      skuAttrNameList = json['skuAttrNameList'].cast<String>();
    }
    examType = json['examType'];
    if (json["skuModels"] != null) {
      skuModels = <SkuModel>[];
      json["skuModels"].forEach((v) {
        skuModels!.add(SkuModel.fromJson(v));
      });
    }
    recommend = json["recommend"];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['createdTime'] = createdTime;
    data['modifyTime'] = modifyTime;
    data['createdBy'] = createdBy;
    data['modifyBy'] = modifyBy;
    data['id'] = id;
    data['name'] = name;
    data['sort'] = sort;
    data['industryId'] = industryId;
    data['examId'] = examId;
    data['price'] = price;
    data['discountPrice'] = discountPrice;
    data['agentPrice'] = agentPrice;
    data['tmPrice'] = tmPrice;
    data['tagIds'] = tagIds;
    data['days'] = days;
    data['endDate'] = endDate;
    data['remark'] = remark;
    data['enable'] = enable;
    if (skuAttrs != null) {
      data['skuAttrs'] = skuAttrs!.toJson();
    }
    data['industryName'] = industryName;
    data['examName'] = examName;
    data['tagNameList'] = tagNameList;
    data['tagTypeList'] = tagTypeList;
    data['skuAttrNameList'] = skuAttrNameList;
    data['examType'] = examType;
    if (skuModels != null) {
      data['skuModels'] = skuModels!.map((v) => v.toJson()).toList();
    }
    data["recommend"] = recommend;
    return data;
  }
}

class SkuAttrs {
  List<String>? guipeikemu;

  SkuAttrs({
    this.guipeikemu,
  });

  SkuAttrs.fromJson(Map<String, dynamic> json) {
    if (json["guipeikemu"] != null) {
      guipeikemu = json['guipeikemu'].cast<String>();
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['guipeikemu'] = guipeikemu;
    return data;
  }
}

/// sku管理
class SkuModel {
  String? createdTime;
  String? modifyTime;
  String? createdBy;
  String? modifyBy;
  String? id;

  // 已购名称
  String? name;

  // 排序
  int? sort;

  // 行业id 值为gjtk时表示考试为高教题库
  String? industryId;

  // 考试id
  String? examId;

  // 套餐id
  String? packageId;

  // 原价/分
  int? price;

  // 折扣价/分
  int? discountPrice;

  // 代理价/分
  int? agentPrice;

  // 天猫价/分
  int? tmPrice;

  // 售卖数量
  int? sellCount;

  // skuAttrIds
  List<String>? skuAttrIds;

  // 科目集合
  List<int>? categoryIds;

  // 产品集合
  List<String>? productIds;
  String? remark;

  // 是否上下架
  bool? enable;

  // 行业名
  String? industryName;

  // 考试名
  String? examName;
  String? packageName;
  List<String>? categoryNameList;

  // 科目集合
  List<CategoryModel>? categoryList;
  List<String>? skuAttrNameList;
  String? examType;

  // 有效期开始时间
  String? startTime;

  // 有效期结束时间
  String? endTime;

  // 资产是否有效
  String? efficient;

  // 栏目类型
  List<String>? columnType;

  /// 是否选中，自定义
  bool isSelect;

  SkuModel({
    this.createdTime,
    this.modifyTime,
    this.createdBy,
    this.modifyBy,
    this.id,
    this.name,
    this.sort,
    this.industryId,
    this.examId,
    this.packageId,
    this.price,
    this.discountPrice,
    this.agentPrice,
    this.tmPrice,
    this.sellCount,
    this.skuAttrIds,
    this.categoryIds,
    this.productIds,
    this.remark,
    this.enable,
    this.industryName,
    this.examName,
    this.packageName,
    this.categoryNameList,
    this.categoryList,
    this.skuAttrNameList,
    this.examType,
    this.startTime,
    this.endTime,
    this.efficient,
    this.columnType,
    this.isSelect = false,
  });

  SkuModel.fromJson(Map<String, dynamic> json) : isSelect = false {
    createdTime = json['createdTime'];
    modifyTime = json['modifyTime'];
    createdBy = json['createdBy'];
    modifyBy = json['modifyBy'];
    id = json['id'];
    name = json['name'];
    sort = json['sort'];
    industryId = json['industryId'];
    examId = json['examId'];
    packageId = json['packageId'];
    price = json['price'];
    discountPrice = json['discountPrice'];
    agentPrice = json['agentPrice'];
    tmPrice = json['tmPrice'];
    sellCount = json['sellCount'];
    if (json["skuAttrIds"] != null) {
      skuAttrIds = json['skuAttrIds'].cast<String>();
    }
    if (json["categoryIds"] != null) {
      categoryIds = json['categoryIds'].cast<int>();
    }
    if (json["productIds"] != null) {
      productIds = json['productIds'].cast<String>();
    }
    remark = json['remark'];
    enable = json['enable'];
    industryName = json['industryName'];
    examName = json['examName'];
    packageName = json['packageName'];
    if (json["categoryNameList"] != null) {
      categoryNameList = json['categoryNameList'].cast<String>();
    }
    if (json["categoryList"] != null) {
      categoryList = <CategoryModel>[];
      json["categoryList"].forEach((v) {
        categoryList!.add(CategoryModel.fromJson(v));
      });
    }
    if (json["skuAttrNameList"] != null) {
      skuAttrNameList = json['skuAttrNameList'].cast<String>();
    }
    examType = json['examType'];
    startTime = json['startTime'];
    endTime = json['endTime'];
    efficient = json['efficient'];
    if (json["columnType"] != null) {
      columnType = json['columnType'].cast<String>();
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['createdTime'] = createdTime;
    data['modifyTime'] = modifyTime;
    data['createdBy'] = createdBy;
    data['modifyBy'] = modifyBy;
    data['id'] = id;
    data['name'] = name;
    data['sort'] = sort;
    data['industryId'] = industryId;
    data['examId'] = examId;
    data['packageId'] = packageId;
    data['price'] = price;
    data['discountPrice'] = discountPrice;
    data['agentPrice'] = agentPrice;
    data['tmPrice'] = tmPrice;
    data['sellCount'] = sellCount;
    data['skuAttrIds'] = skuAttrIds;
    data['categoryIds'] = categoryIds;
    data['productIds'] = productIds;
    data['remark'] = remark;
    data['enable'] = enable;
    data['industryName'] = industryName;
    data['examName'] = examName;
    data['packageName'] = packageName;
    data['categoryNameList'] = categoryNameList;
    if (categoryList != null) {
      data['categoryList'] = categoryList!.map((v) => v.toJson()).toList();
    }
    data['skuAttrNameList'] = skuAttrNameList;
    data['examType'] = examType;
    data['startTime'] = startTime;
    data['endTime'] = endTime;
    data['efficient'] = efficient;
    data['columnType'] = columnType;
    return data;
  }
}
